package com.rocbrid.product.controller;

import com.rocbrid.product.bean.Product;
import com.rocbrid.product.service.ProductService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.http.HttpRequest;
//@RequestMapping("/api/product")
@RestController
public class ProductController {
    @Autowired
    ProductService productService;

    @GetMapping("/product/{id}")
    public Product getProduct(@PathVariable("id") Long prductId,
                              HttpServletRequest request) {
        String token = request.getHeader("X-Token");
        System.out.println("通过Feign请求拦截器添加的Token"+token);
        System.out.println("被远程调用了");
        Product product = productService.getProductByid(prductId);

        return product;
    }
}
